package yag.battle.model;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Created by user on 31.08.2014.
 */
@Component
@Scope("prototype")
public class Battle {
    Army firstArmy = null;
    Army seconArmy = null;

    public Battle() {
    }


    public int doBattle() {

        int army1Health = firstArmy.getHealth();
        int army2Health = seconArmy.getHealth();

        int army1Dmg = firstArmy.getDamage();
        int army2Dmg = seconArmy.getDamage();

        System.out.println("First army: ");
        System.out.println("Health: " + army1Health + " || DMG: " + army1Dmg);
        System.out.println("Second army: ");
        System.out.println("Health: " + army2Health + " || DMG: " + army2Dmg);


        double first = army1Health / army2Dmg;
        double second = army2Health / army1Dmg;

        if (first < second) {
            System.out.println("WIN second army");
            return -1;

        } else if (first > second) {
            System.out.println("WIN first army");
            return 1;
        } else {
            System.out.println("DRAW");
            return 0;
        }


    }

    public Army getFirstArmy() {
        return firstArmy;
    }

    public void setFirstArmy(Army firstArmy) {
        this.firstArmy = firstArmy;
    }

    public Army getSeconArmy() {
        return seconArmy;
    }

    public void setSeconArmy(Army seconArmy) {
        this.seconArmy = seconArmy;
    }
}
